<?php

/**
 * This is the model class for table "tbl_member_url".
 *
 * The followings are the available columns in table 'tbl_member_url':
 * @property integer $member_url_id
 * @property integer $member_id
 * @property string $personal_url
 * @property string $company_url
 * @property string $blog
 * @property string $msn
 * @property string $facebook
 * @property string $linkedin
 * @property string $other_1_name
 * @property string $other_1_url
 * @property string $other_2_name
 * @property string $other_2_url
 *
 * The followings are the available model relations:
 * @property TblMember $member
 */
class Urls extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Urls the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_member_url';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('member_id', 'numerical', 'integerOnly'=>true),
			array('personal_url, company_url, blog, msn, facebook, linkedin, other_1_name, other_1_url, other_2_name, other_2_url', 'length', 'max'=>50),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('member_url_id, member_id, personal_url, company_url, blog, msn, facebook, linkedin, other_1_name, other_1_url, other_2_name, other_2_url', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'member' => array(self::BELONGS_TO, 'TblMember', 'member_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'member_url_id' => 'Member Url',
			'member_id' => 'Member',
			'personal_url' => 'Personal Url',
			'company_url' => 'Company Url',
			'blog' => 'Blog',
			'msn' => 'Msn',
			'facebook' => 'Facebook',
			'linkedin' => 'Linkedin',
			'other_1_name' => 'Other 1 Name',
			'other_1_url' => 'Other 1 Url',
			'other_2_name' => 'Other 2 Name',
			'other_2_url' => 'Other 2 Url',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('member_url_id',$this->member_url_id);
		$criteria->compare('member_id',$this->member_id);
		$criteria->compare('personal_url',$this->personal_url,true);
		$criteria->compare('company_url',$this->company_url,true);
		$criteria->compare('blog',$this->blog,true);
		$criteria->compare('msn',$this->msn,true);
		$criteria->compare('facebook',$this->facebook,true);
		$criteria->compare('linkedin',$this->linkedin,true);
		$criteria->compare('other_1_name',$this->other_1_name,true);
		$criteria->compare('other_1_url',$this->other_1_url,true);
		$criteria->compare('other_2_name',$this->other_2_name,true);
		$criteria->compare('other_2_url',$this->other_2_url,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}